<?php
/* Usage:
 * info_struct_to_html($info);
 * convert info_struct to html table code
 * paramter:
 * $info - info_struct with the struct to show
 * return:
 * nothing
 * remark:
 * html code will be showed where this function is called
 */
function info_struct_to_html($info) {
?>
  <table border="0">
  <tr>
  <td>ID:</td>
  <td id="ref_id"><?php echo isset($info->id) ? $info->id : '' ?></td>
  </tr>
  <tr>
  <tr>
  <td>Title:</td>
  <td id="ref_title"><?php echo isset($info->title) ? $info->title : '' ?></td>
  </tr>
  <tr>
  <td>Author:</td>
  <td id="ref_author"><?php echo isset($info->author) ? $info->author : '' ?></td>
  </tr>
  <tr>
  <td>Year:</td>
  <td id="ref_year"><?php echo isset($info->year) ? $info->year : '' ?></td>
  </tr>
  <tr>
  <td>Journal:</td>
  <td><?php echo isset($info->journal) ? $info->journal : '' ?></td>
  </tr>
  <tr>
  <td>Volume:</td>
  <td><?php echo isset($info->volume) ? $info->volume : '' ?></td>
  </tr>
  <tr>
  <td>Number:</td>
  <td><?php echo isset($info->number) ? $info->number : '' ?></td>
  </tr>
  <tr>
  <td>Pages:</td>
  <td><?php echo isset($info->pages) ? $info->pages : '' ?></td>
  </tr>
  <tr>
  <td>Month:</td>
  <td><?php echo isset($info->month) ? $info->month : '' ?></td>
  </tr>
  <tr>
  <td>Other:</td>
  <td><?php echo isset($info->other) ? $info->other : '' ?></td>
  </tr>
  <tr>
  <td>Zmath:</td>
  <td><?php echo isset($info->zmath) ? $info->zmath : '' ?></td>
  </tr>
  <tr>
  <td>ArXiv:</td>
  <td><?php echo isset($info->arxiv) ? $info->arxiv : '' ?></td>
  </tr>
  <tr>
  <td>DOI:</td>
  <td><?php echo isset($info->doi) ? $info->doi : '' ?></td>
  </tr>
  <tr>
  <td colspan="2"><?php echo isset($info->note) ? $info->note : '' ?></td>
  </tr>
  </table>
<?php
}

/* gets the data from a URL 
 * alternative for file_get_contents if curl is installed
 * paramter:
 * $url = url of the content you want to get
 * $timeout = timeout how long you wait for the content to get
 * $referer = referer if needed by some website
 * return:
 * string with the content you want to access
 */

function curl_file_get_contents($url, $timeout = 5, $referer = "") {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}

?>
